#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include <QVBoxLayout>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QWidget *widget = NULL;
    QVBoxLayout *layout = NULL;
    QLabel *label = NULL;

    // widget 1
    widget = new QWidget(this);
    layout = new QVBoxLayout;
    label = new QLabel(tr("This is widget One"), this);
    label->setAlignment(Qt::AlignCenter);
    layout->addWidget(label);
    widget->setLayout(layout);
    widget->setStyleSheet("QWidget {font-size: 24px; color: white; background-color: red}");
    ui->stackedWidget->addWidget(widget);

    // widget 2
    widget = new QWidget(this);
    layout = new QVBoxLayout;
    label = new QLabel(tr("This is widget Two"), this);
    label->setAlignment(Qt::AlignCenter);
    layout->addWidget(label);
    widget->setLayout(layout);
    widget->setStyleSheet("QWidget {font-size: 24px; color: black; background-color: yellow}");
    ui->stackedWidget->addWidget(widget);

    // widget 3
    widget = new QWidget(this);
    layout = new QVBoxLayout;
    label = new QLabel(tr("This is widget Three"), this);
    label->setAlignment(Qt::AlignCenter);
    layout->addWidget(label);
    widget->setLayout(layout);
    widget->setStyleSheet("QWidget {font-size: 24px; color: white; background-color: green}");
    ui->stackedWidget->addWidget(widget);

    // widget 4
    widget = new QWidget(this);
    layout = new QVBoxLayout;
    label = new QLabel(tr("This is widget Four"), this);
    label->setAlignment(Qt::AlignCenter);
    layout->addWidget(label);
    widget->setLayout(layout);
    widget->setStyleSheet("QWidget {font-size: 24px; color: black; background-color: cyan}");
    ui->stackedWidget->addWidget(widget);

    // widget 5
    widget = new QWidget(this);
    layout = new QVBoxLayout;
    label = new QLabel(tr("This is widget Five"), this);
    label->setAlignment(Qt::AlignCenter);
    layout->addWidget(label);
    widget->setLayout(layout);
    widget->setStyleSheet("QWidget {font-size: 24px; color: white; background-color: blue}");
    ui->stackedWidget->addWidget(widget);

    m_label = new QLabel(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_btnWidget1_clicked()
{
    ui->stackedWidget->switchIndex(0);
}

void MainWindow::on_btnWidget2_clicked()
{
    ui->stackedWidget->switchIndex(1);
}

void MainWindow::on_btnWidget3_clicked()
{
    ui->stackedWidget->switchIndex(2);
}

void MainWindow::on_btnWidget4_clicked()
{
    ui->stackedWidget->switchIndex(3);
}

void MainWindow::on_btnWidget5_clicked()
{
    ui->stackedWidget->switchIndex(4);
}
